library(WGCNA)
library(dplyr)
load("datatraitbase.Rdata")
args <- commandArgs(T)
## 3 trait
traitData <- args[1]
Title = args[2]
trait <- read.delim(traitData,header = T,
                    sep = "\t")
if (ncol(trait) == 2) {
  x <- trait
  Tcol = as.character(unique(x[,2]))
  b <- list()
  for (i in 1:length(Tcol)) {
    b[[i]] = data.frame(row.names = x[,1],
                        levels = ifelse(x[,2] == Tcol[i],1,0))
  }
  c <- bind_cols(b)
  c <- data.frame(row.names = x$name,
                  c)
  colnames(c) = Tcol
  pheTmp <- c
} else {
  pheTmp = data.frame(row.names = trait[,1],
                      trait[,-1])
}
source("/public/home/wangxiao/03.MyScript/MyScript/R/01.WGCNA/11.04.WGCNA.moduleTrait.R")
phenotype = pheTmp
WGCNA.ModuleTrait(Title = Title,
                  phenotype = phenotype)
